package io.wongxd.demo.page

import androidx.compose.animation.*
import androidx.compose.animation.core.tween
import androidx.compose.foundation.layout.*
import androidx.compose.material3.Button
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.State
import androidx.compose.runtime.getValue
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import io.wongxd.solution.baseView.BaseComposeFragment
import io.wongxd.solution.compose.custom.dialog.WDialog
import io.wongxd.solution.compose.custom.dialog.WState

class FgtDialog : BaseComposeFragment() {

    override fun lazyInit() {

    }

    @OptIn(ExperimentalAnimationApi::class)
    @Composable
    override fun Render() {
        // A surface container using the 'background' color from the theme
        Surface(
            modifier = Modifier.fillMaxSize(),
            color = MaterialTheme.colorScheme.background
        ) {
            var dialogVisible by WState(value = false)
            WDialog(
                visible = dialogVisible,
                durationMillis = 2000,
                position = Alignment.TopCenter,
                onDismiss = { dialogVisible = false },
            ) {
                Text(
                    text = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",
                    color = Color.White,
                    fontSize = 13.sp,
                    textAlign = TextAlign.Justify
                )
            }
            var dialogVisible2 by WState(value = false)
            WDialog(
                visible = dialogVisible2,
                durationMillis = 2000,
                position = Alignment.TopCenter,
                onDismiss = { dialogVisible2 = false },
            ) {
                Text(
                    text = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",
                    color = Color.White,
                    fontSize = 13.sp,
                    textAlign = TextAlign.Justify
                )
            }
            var dialogVisible3 by WState(value = false)
            WDialog(
                visible = dialogVisible3,
                durationMillis = 2000,
                position = Alignment.BottomCenter,
                onDismiss = { dialogVisible3 = false },
            ) {
                Text(
                    text = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",
                    color = Color.White,
                    fontSize = 13.sp,
                    textAlign = TextAlign.Justify
                )
            }
            var dialogVisible4 by WState(value = false)
            WDialog(
                visible = dialogVisible4,
                durationMillis = 0,
                position = Alignment.Center,
                onDismiss = { dialogVisible4 = false },
                outSideDismiss = true
            ) {
                Text(
                    text = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",
                    color = Color.White,
                    fontSize = 13.sp,
                    textAlign = TextAlign.Justify
                )
            }

            Column(
                modifier = Modifier.fillMaxSize(),
                verticalArrangement = Arrangement.Center,
                horizontalAlignment = Alignment.CenterHorizontally
            ) {
                Button(onClick = { dialogVisible = true }) {
                    Text(text = "Call Me!", fontSize = 13.sp)
                }
                Spacer(Modifier.height(8.dp))
                Button(onClick = { dialogVisible2 = true }) {
                    Text(text = "Call Me",  fontSize = 13.sp)
                }
                Spacer(Modifier.height(8.dp))
                Button(onClick = { dialogVisible3 = true }) {
                    Text(text = "Call Me",  fontSize = 13.sp)
                }
                Spacer(Modifier.height(8.dp))
                Button(onClick = { dialogVisible4 = true }) {
                    Text(text = "Call Me", fontSize = 13.sp)
                }
            }
        }
    }

    @Preview(showBackground = true, backgroundColor = 0xffffffff)
    @Composable
    fun RenderPreView() {

    }
}